

<html>
  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="layout" content="main" />
  <g:set var="entityName" value="${message(code: 'question.label', default: 'Question')}" />
  <title><g:message code="default.edit.label" args="[entityName]" /></title>
</head>
<body>
  <div class="nav">
	<span class="menuButton"><a class="home" href="${createLink(uri: '/')}">Home</a></span>
	<span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
	<span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
  </div>
  <div class="body">
	<h1><g:message code="default.edit.label" args="[entityName]" /></h1>
	<g:if test="${flash.message}">
	  <div class="message">${flash.message}</div>
	</g:if>
	<g:hasErrors bean="${questionInstance}">
	  <div class="errors">
		<g:renderErrors bean="${questionInstance}" as="list" />
	  </div>
	</g:hasErrors>
	<g:form method="post" >
	  <g:hiddenField name="id" value="${questionInstance?.id}" />
	  <g:hiddenField name="version" value="${questionInstance?.version}" />
	  <div class="dialog">
		<table>
		  <tbody>

			<tr class="prop">
			  <td valign="top" class="name">
				<label for="content"><g:message code="question.content.label" default="Content" /></label>
			  </td>
			  <td valign="top" class="value ${hasErrors(bean: questionInstance, field: 'content', 'errors')}">
		  <g:textArea name="content" cols="40" rows="5" value="${questionInstance?.content}" />
		  </td>
		  </tr>

		  <tr class="prop">
			<td valign="top" class="name">
			  <label for="type"><g:message code="question.type.label" default="Type" /></label>
			</td>
			<td valign="top" class="value ${hasErrors(bean: questionInstance, field: 'type', 'errors')}">
		  <g:select name="type" from="${['multi_select','answer']}" value="${questionInstance?.type}" noSelection="['null':'-请选择-']"/>
		  </td>
		  </tr>

		  <tr class="prop">
			<td valign="top" class="name">
			  <label for="multiSelect"><g:message code="question.multiSelect.label" default="Multi Select" /></label>
			</td>
			<td valign="top" class="value ${hasErrors(bean: questionInstance, field: 'multiSelect', 'errors')}">
		  <g:textField name="multiSelect" value="${fieldValue(bean: questionInstance, field: 'multiSelect')}" />
		  </td>
		  </tr>

		  <tr class="prop">
			<td valign="top" class="name">
			  <label for="questionnaire"><g:message code="question.questionnaire.label" default="Questionnaire" /></label>
			</td>
			<td valign="top" class="value ${hasErrors(bean: questionInstance, field: 'questionnaire', 'errors')}">
		  <g:select name="questionnaire.id" from="${Questionnaire.list()}" optionKey="id" value="${questionInstance?.questionnaire?.id}"  />
		  </td>
		  </tr>

		  <tr class="prop">
			<td valign="top" class="name">
			  <label for="questionItems"><g:message code="question.questionItems.label" default="Question Items" /></label>
			</td>
			<td valign="top" class="value ${hasErrors(bean: questionInstance, field: 'questionItems', 'errors')}">

			  <ul>
				<g:each in="${questionInstance?.questionItems?}" var="q">
				  <li><g:link controller="questionItem" action="show" id="${q.id}">${q?.encodeAsHTML()}</g:link></li>
				</g:each>
			  </ul>
		  <g:link controller="questionItem" action="create" params="['question.id': questionInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'questionItem.label', default: 'QuestionItem')])}</g:link>
		  <g:link controller="questionItem" action="createall" params="['question.id': questionInstance?.id]">添加多个选项</g:link>
		  </td>
		  </tr>

		  </tbody>
		</table>
	  </div>
	  <div class="buttons">
		<span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
		<span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
	  </div>
	</g:form>
  </div>
</body>
</html>
